package com.ai.demo.config;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.deepseek.DeepSeekChatModel;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.ai.openai.OpenAiChatOptions;
import org.springframework.ai.openai.api.OpenAiApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.Duration;

@Configuration
public class ChatClientConfig {
    /**
     * 创建一个DeepSeekChatModel类型的Bean，用于配置DeepSeek AI的参数
     * @param chatModel
     * @return
     */
    @Autowired
    private OpenAiApi baseOpenAiApi;

    @Bean
    public ChatClient deepSeekAiChatClient(DeepSeekChatModel chatModel) {
        return ChatClient.create(chatModel);
    }

    @Bean
    public ChatClient openAiChatClient(OpenAiChatModel chatModel) {
        OpenAiChatModel openAiChatModel = chatModel.mutate()
                .openAiApi(baseOpenAiApi)
                .defaultOptions(OpenAiChatOptions.builder().model("deepseek-chat").temperature(0.7).build())
                .build();
        return ChatClient.builder(openAiChatModel).build();
    }


}
